{SysAdd} = require "./SysAdd"
{Srv} = require "Srv"
{EmpAdd} = require "./EmpAdd"

SupperClzz = SysAdd
exports["@Et_psw"] = {comment:"修改密码"}
exports.Et_psw = new Class
  Extends: SupperClzz
  options:
    headArr: ["old_psw","psw"]
    headObj:
      "old_psw":"原密码"
      "psw":"新密码"
    $vdts: ["psw"]
  initPg: ->
    t = this
    o = t.options
    elt = o.ele
    yield SupperClzz.prototype.initPg.apply t,arguments
    return
  initThisSrv: ->
    t = this
    o = t.options
    elt = o.ele
    o.thisSrv = new Srv clz:"sys.Et_pswSrv"
    o.thisSrv.options.ele = elt
    return
  pswVdt: (key,val,id)-> yield EmpAdd.prototype.passwordVdt.apply this,arguments
  confirmButClk: (but,e,headArr)->
    t = this
    o = t.options
    elt = o.ele
    but.set "disabled",true if but
    isPass = yield t.runAllVdts()
    if !isPass
      but.set "disabled",false if but
      return
    eny = {}
    yield t.getPgVal eny,{cmpOldVal:false}
    rltSet = yield o.thisSrv.ajax "et_psw",[eny.old_psw,eny.psw]
    but.set "disabled",false if but
    if rltSet
      window.ncWg.addNotice "info","密码修改成功,请牢记新密码!",3
      cancelBut = elt.getE ".cancelBut"
      yield t.cancelButClk cancelBut,undefined,false
    return
  